package cn.itlaobing.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Main {

	public static void main(String[] args) {
		UserDao userDaoTarget = new UserDaoImpl();
		UserDao userDao=(UserDao) Proxy.newProxyInstance(UserDao.class.getClassLoader(),
				UserDaoImpl.class.getInterfaces(), 
				new InvocationHandler() {
					
					@Override
					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
						System.out.println("【日志】：保存之前");
						Object result= method.invoke(userDaoTarget, args);
						System.out.println("【日志】：保存之hou");
						return result;
					}
				});
		userDao.save("hudsaiud");
	}

}
